<template>
  <div>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="goods_id" label="编号" width="180"></el-table-column>
      <el-table-column prop="goods_name" label="名称" width="180"></el-table-column>
      <el-table-column prop="goods_type" label="类别"></el-table-column>
      <el-table-column prop="store_count" label="库存"></el-table-column>
      <el-table-column prop="is_show" label="展示"></el-table-column>
      <el-table-column prop="is_hot" label="热"></el-table-column>
    </el-table>
    <el-pagination background layout="prev, pager, next" :total="total" :page-size="pageSize" @current-change="pageNow"></el-pagination>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: [],
      total: 0,
      pageSize: 5,
      currentPage: 1
    };
  },
  created() {
    this.showAll();
  },
  methods: {
    pageNow: function(page) {
      var _self = this;
      _self.currentPage = page;
      this.showAll();
    },
    showAll: function() {
      var _self = this;
      _self.$ajax
        .get('http://www.shop.com/month', {
          params: {
            page:_self.currentPage
          }
        })
        .then(function(response) {
          // console.log(response);
          if (response.data.code == 0) {
            _self.tableData = response.data.data.data;
            _self.total = response.data.data.total;
          }
        })
        .catch(function(error) {
          console.log(error);
        });
    }
  }
};
</script>

<style></style>
